﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;

namespace Kxzz.IconUtil
{
    public class IconHelper
    {
        private ArrayList alIconMsg = new ArrayList();
        private ArrayList alIconLogin = new ArrayList();
        private int intIconMsg = 0;
        private static int intIconLogin = 0;

        public IconHelper()
        {
            IconConverter ic = new IconConverter();

            this.alIconMsg.Add(ConvertToIcon(Properties.Resources.Msg1));
            this.alIconMsg.Add(ConvertToIcon(Properties.Resources.Msg2));
            this.alIconMsg.Add(ConvertToIcon(Properties.Resources.Msg3));

            this.alIconLogin.Add(Properties.Resources.Kxzz16x16);
            this.alIconLogin.Add(Properties.Resources.Off16X16);
        }

        /// <summary>
        /// 转换成Icon
        /// </summary>
        /// <param name="bitMap"></param>
        /// <returns></returns>
        public Icon ConvertToIcon(Bitmap bitMap)
        {
            return Icon.FromHandle(bitMap.GetHicon());
        }

        /// <summary>
        /// 显示有新消息图标
        /// </summary>
        /// <param name="notifyIcon"></param>
        public void ShowMsg(NotifyIcon notifyIcon)
        {
            //ICO转换控制。
            if (intIconMsg < 3)
            {
                notifyIcon.Icon = (Icon)alIconMsg[intIconMsg];
                intIconMsg++;
                return;
            }
            else
                notifyIcon.Icon = (Icon)alIconMsg[0];
            intIconMsg = 1;
        }

        /// <summary>
        /// 用户登陆图标
        /// </summary>
        /// <param name="notifyIcon"></param>
        public void ShowLogin(NotifyIcon notifyIcon)
        {
            notifyIcon.Icon = (Icon)alIconLogin[intIconLogin % 2];
            intIconLogin++;
        }
    }
}
